<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	
<%@page import="com.lovo.bbs.vo.*,com.lovo.bbs.bo.*,java.util.*"%>

<%
    //请求页
    String queryPages = (String)request.getAttribute("queryPage");
	if(queryPages==null){
	  queryPages="1";
	}
	int queryPage=Integer.parseInt(queryPages);
    
    ArrayList<LinkVo> forumlinkList = new LinkBo().getAllLink();
   
	int pageCount = forumlinkList.size();
	int pageNum = (pageCount % 20 == 0) ? (pageCount / 20) : (pageCount / 20 + 1);
	Iterator it;
%>
<html>
	<head>
		<link href="../../../css/admin.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
		function preModify(linkid,linkname,reads,url){
		   document.frmMain.linkid.value=linkid;	   
		   document.frmMain.linkname.value=linkname;

		   document.frmMain.reads.value=reads;
		   document.frmMain.url.value=url;		  
		   document.frmMain.opType.value="2";
		   document.frmMain.action="friendForumUpdatePage.jsp";
		   document.frmMain.submit();
		}		
		function preDelete(linkid,linkname,reads,url){
		   document.frmMain.linkid.value=linkid;	   
		   document.frmMain.linkname.value=linkname;

		   document.frmMain.reads.value=reads;
		   document.frmMain.url.value=url;
		   document.frmMain.opType.value="3";
		   document.frmMain.action="friendForumUpdatePage.jsp";
		   document.frmMain.submit();		   
		}
		
		function preInsert(){
		   document.frmMain.opType.value="1";
		   document.frmMain.action="friendForumUpdatePage.jsp";
		   document.frmMain.submit();	
		}
		</script>
	</head>
	<body>
	  <form  method="post" name="frmMain">
		<table class="navigation" style="width:98%" align="center">
				<tr>
					<td>
						当前位置: 友情链接管理
					</td>
				</tr>
		</table>
		<table border="0" cellspacing="0" cellpadding="0" width="98%" align="center">
			<tr>
				<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="4">
						<tr>
							<td id="content_bar">
								<a class="content_total">友情链接总数: <%=pageCount%> ,第<%=queryPage%>页	总<%=pageNum%>页 </a>
									<%	for (int i = 1; i <= pageNum; i++) {
											if (i == queryPage) {
									%>
									<a class="content_pasges_c"><%=i%></a>
									<%} else {%>
									<a class="content_pasges_a"	href="FriendForumQuery?queryPage=<%=i%>"><%=i%></a>
									<%}	}%>
									<input type="button" style="float:right"	class="button" value=" 增加友情链接 " onclick="preInsert();">
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td>
						<table border="0" cellspacing="1" cellpadding="4" class="tableborder" style="background-color:#CCFFFF; border:#99FFCC 0px solid">
							<tr class="header">
								<td width="20%">
									友情链接名称
								</td>
								
								<td width="20%">
									说明
								</td>
								<td width="20%">
									URL链接地址
								</td>
								<td width="15%">
									操作
								</td>
							</tr>
							<%  if (forumlinkList == null) {
									forumlinkList = new ArrayList();
									System.out.println("对象为空");
								}
								it = forumlinkList.iterator();
								if (it != null) {
									while (it.hasNext()) {
										LinkVo forumlinkListData = (LinkVo) (it.next());
							%>
							<tr class="row">
								<td>
									<%=forumlinkListData.getLinkname()%>
								</td>
							
								<td>
									<%=forumlinkListData.getAboutLink()%>
								</td>
								<td>
									<%=forumlinkListData.getLinkurl()%>
								</td>
								<td>
									<input type="button" value=" 修改 " class="button" onclick="preModify('<%=forumlinkListData.getLinkid()%>','<%=forumlinkListData.getLinkname()%>','<%=forumlinkListData.getAboutLink()%>','<%=forumlinkListData.getLinkurl()%>')">
									<input type="button" value=" 删除 " class="button" style="color:#ff0000;" onclick="preDelete('<%=forumlinkListData.getLinkid()%>','<%=forumlinkListData.getLinkname()%>','<%=forumlinkListData.getAboutLink()%>','<%=forumlinkListData.getLinkurl()%>')">
								</td>
							</tr>
							<% }} %>
						</table>
					</td>
				</tr>
			</table>
			<br>
			<input type="hidden" name="linkid" value="">
			<input type="hidden" name="linkname" value="">
			<input type="hidden" name="reads" value="">
			<input type="hidden" name="url" value="">
			
			<input type="hidden" name="opType" value="">
			
			<input type="hidden" name="queryPage" value="<%=queryPage%>">
			
		</form>
	</body>
</html>
